﻿using FluentValidation;
using Giant.Admin.Models.Sites;
using Giant.Core.Domain.Sites;
using Giant.Data;
using Giant.Services.Localization;
using Giant.Web.Framework.Validators;

namespace Giant.Admin.Validators.Sites
{
    public partial class SiteValidator : BaseValidator<SiteModel>
    {
        public SiteValidator(ILocalizationService localizationService, IDbContext dbContext)
        {
            RuleFor(x => x.Name).NotEmpty().WithMessage(localizationService.GetResource("Admin.Configuration.Sites.Fields.Name.Required"));
            RuleFor(x => x.Url).NotEmpty().WithMessage(localizationService.GetResource("Admin.Configuration.Sites.Fields.Url.Required"));

            SetStringPropertiesMaxLength<Site>(dbContext);
        }
    }
}